const Crawler = require('../libs/crawler');

//爬取轮播图
Crawler({
    url: 'https://yuedu.baidu.com/',
    callback () {
        const $ = window.$,
              $item = $('#banner .img-list li');

        const data = [];

        $item.each((index, item) => {
            const $el = $(item),
                  $elLink = $el.find('a');

            const dataItem = {
                  cid: index + 1,
                  href: $elLink.prop('href'),
                  title: '暂无',
                  imgUrl: $elLink.find('img').prop('src'),
                  imgKey: '',//因为我们之后要给图片另起名称才好保证放七牛上的图片的名称唯一性，所以这个imgKey要暂时为空才行
            }

            data.push(dataItem);
        })

        return data;
    }
});